Group Property Example

The following example creates three sets of lightweight OptionButton controls. To try the example, place six OptionButton controls on a form. Paste the code into the Declarations section of the code module, and start the project.

Option Explicit

Private Sub Form_Load()
   Dim i As Integer
   For i = 0 To 5
      Select Case i
         Case 0 To 1
            Me.Controls(i).Group = "Fish"
            Me.Controls(i).Caption = "Fish " & i
         Case 2 To 3
            Me.Controls(i).Group = "Fowl"
            Me.Controls(i).Caption = "Fowl " & i
         Case 4 To 5
            Me.Controls(i).Group = "Dinosaur"
            Me.Controls(i).Caption = "Dinosaur " & i
      End Select
   Next i
End Sub